package opl.ui;

import java.util.List;

import opl.dal.DataAccess;
import opl.entities.NotificationDetails;
import opl.ui.adapters.NotificationAdapter;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;

public class NotificationsActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.notifications);		
		loadNotifications();
	}

	private void loadNotifications() {
		ListView lvNotifications=(ListView) findViewById(R.id.lvNotifications);	
		DataAccess da=new DataAccess(this);
		List<NotificationDetails> lstNotifications=da.getNotifications();
		
		if(lstNotifications.size()==0){
			NotificationDetails detail=new NotificationDetails();
			detail.setCaption("No notifications found!!");
			lstNotifications.add(detail);
		}
		
		da.close();
		
		NotificationAdapter adptr=new NotificationAdapter(this, lstNotifications);
		lvNotifications.setAdapter(adptr);
	}
	
}
